<?php
namespace app\api\controller;

use app\common\BaseController;
use think\Request;


/**
 * 
 */
class Meeting extends BaseController
{
	private $tables = 'meeting';
	private $table_view = 'view_meeting';
    private $tables_view_app_meet_info = 'view_new_app_meeting_info';
	
    public function _initialize(){
        $this->noNeedLogin = ['session_set',''];
    } 
    /**预约列表
     * [meeting_list description]
     * @HtttpRequest                          get|
     * @Author       GNLEON
     * @Param
     * @DateTime     2020-07-13T09:41:49+0800
     * @LastTime     2020-07-13T09:41:49+0800
     * @return       [type]                   [description]
     */
    public function meeting_list(){
    	$type = trim($this->request->param('yueType')); //vister-我是访客  app-我是受访人
    	$offset = trim($this->request->param('offset'));
        $length = trim($this->request->param('length'));
        // $Keyword = trim($this->request->param('keyword'));
        // $search[0] =  $Keyword?'businessName like "%'.$Keyword.'%"':'';
        switch ($type) {
        	case 'vister':
        		$search[0] = $type?'vister_uid = '.$this->uid:'';
        		break;
        	case 'app':
        		$search[0] = $type?'app_uid = '.$this->uid:'';
        		break;
        	default:
        		$search[0] = '';
        		# code...
        		break;
        }
        $where =  $search[0].' and deleteTime is null and app_uid is not null';
        // foreach ($search as $key => $value) {
        //     # code...
        //     if($value){
        //         $where=$where.$value.' and ';
        //     }
        // }
        // $where=substr($where,0,strlen($where)-5);
        // var_dump($where);
        // exit();
        //$order = 'confirm_time,createtime asc';
        $order = 'app_visittime desc';
        $data=$this->selectView($this->tables_view_app_meet_info,$where,'*',$offset,$length,$order);   
        $total=$this->total($this->table_view,$where);
        return tojson(['code'=>200,'data'=>$data,'count'=>$total]);

    }

}